function compareVersion(v1, v2) {
    const arr1 = v1.split('.');
    const arr2 = v2.split('.');
    const maxLength = Math.max(arr1.length, arr2.length);

    for (let i = 0; i < maxLength; i++) {
        const num1 = i < arr1.length ? arr1[i] : 0;
        const num2 = i < arr2.length ? arr2[i] : 0;
        if (num1 > num2) {
            return 1;
        } else if (num1 < num2) {
            return -1;
        }
    }

    return 0;
}
function findMaxVersion(versions) {
    let maxVersion = versions[0];

    for (let i = 1; i < versions.length; i++) {
        if (compareVersion(versions[i], maxVersion) > 0) {
            maxVersion = versions[i];
        }
    }

    return maxVersion;
}

// 示例
const versions = ["1.0.0", "1.0.1", "1.0.2.1", "1.1", "2.0", "3.10", "1.2"];
const maxVersion = findMaxVersion(versions);
console.log("最大版本号是:", maxVersion);  // 输出: 最大版本号是: 2.0